package com.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bean.Goods;
import com.bean.Seckill;
import com.bean.User;
import com.dao.SeckillMapper;
import com.service.ISeckillService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author WxrStart
 * @create 2022-06-14 14:39
 */
@Service
public class SeckillServiceImpl extends ServiceImpl<SeckillMapper,Seckill> implements ISeckillService {

    @Autowired
    private SeckillMapper seckillMapper;

    /**
     * 添加秒杀活动
     * @param seckill
     * @return
     */

    @Override
    public Integer addSeckill(Seckill seckill) {
        return seckillMapper.insert(seckill);
    }

    /**
     * 根据商品名查询秒杀活动
     * @param goodsName
     * @return
     */
    @Override
    public Seckill getSeckill(String goodsName) {
       return seckillMapper.getSeckill(goodsName);
    }
    /**
     * 给中间表orders_goods插入数据
     * @param orderId
     * @param goodsId
     * @return
     */
    @Override
    public Integer addorders_goods(Integer orderId, Integer goodsId) {
        return seckillMapper.addorders_goods(orderId,goodsId);
    }

    /**
     * 给中间表user_seckill插入数据
     * @param userId
     * @param seckillId
     * @return
     */
    @Override
    public Integer adduser_seckill(Integer userId, Integer seckillId) {
        return seckillMapper.adduser_seckill(userId,seckillId);
    }

//    /**
//     * 判断用户是否重复参与秒杀活动
//     * @param user
//     * @return false未参加，true已参加
//     */
//    @Override
//    public Boolean getUserBySeckillId(User user) {
//        Integer integer = seckillMapper.selectCountByUserId(user.getUserId());
//        if(integer==0){
//            return false;
//        }else {
//            return true;
//        }
//
//    }


}
